#include <stdio.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char *argv[])
{
    // 2
    printf("I am a process, pid: %d, ppid: %d\n", getpid(), getppid());
    if(argc != 2)
    {
        printf("Usage: %s -[a,b,c,d]\n", argv[0]);
        return 1;
    }
    else if(strcmp(argv[1], "-a") == 0)
    {
        printf("this is function1\n");
    }
    else if(strcmp(argv[1], "-b") == 0)
    {
        printf("this is function2\n");
    }
    else if(strcmp(argv[1], "-c") == 0)
    {
        printf("this is function3\n");
    }
    else if(strcmp(argv[1], "-d") == 0)
    {
        printf("this is function4\n");
    }
    else
    {
        printf("no this function\n");
    }
    // 1
    //int i = 0;
    ////for(i = 0; i < argc; ++i)
    // 验证以NULL结尾
    //for(i = 0; argv[i]; ++i)
    //{
    //    printf("agrv[%d]->%s\n", i, argv[i]);
    //}

    return 0;
}
